#include <algorithm>
#include <cstdio>
#include <map>
std::map <int, int> ma;
int n, a[101];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	std::sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) {
		if(a[i] == 25) {
			ma[a[i]]++;
			continue;
		}
		if(a[i] == 50) {
			if(ma[25]) ma[25]--;
			else {
				printf("NO\n");
				return 0;
			}
			ma[a[i]]++;
		}
		if(a[i] == 100) {
			if(ma[50] >= 1 && ma[25] >= 1) {
				ma[50]--; ma[25]--; continue;
			}
			else if(ma[25] >= 3) {
				ma[25] -= 3; continue;
			}
			else {
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
	return 0;
}
